package com.ruoyi.iot.util;

import cn.hutool.json.JSONObject;
import org.apache.commons.lang3.ObjectUtils;

import java.util.HashMap;
import java.util.Map;

public class EzopenUtil {
    private static String host="https://open.ys7.com/";
    private static String success = "200";
    public static String getToken(String name,String password){
        String url=host+"api/lapp/token/get";
        Map<String, Object> kv=new HashMap<>(4);
        kv.put("appKey",name);
        kv.put("appSecret",password);
        JSONObject token= HttpUtils.postHttpDataJson(url,kv);
        if(ObjectUtils.isNotEmpty(token)){
            String code=token.getStr("code");
            if(success.equals(code)){
                String tokenstr=token.getJSONObject("data").getStr("accessToken");
                return tokenstr;
            }
        }
        return null;
    }
}
